home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / doors_1 / bbslist1.zip / I_F_ENG.H < prev    next >
C/C++ Source or Header  |  1992-05-13  |  5KB  |  98 lines

  1.  
  2. /* This file contains all the definitions needed to access the routines in */
  3. /*  the object file i_f_rtn.obj.  Include this in your source file with    */
  4. /*  the line:   #include "i_f_rtn.h"     and you'll be cooking with gas!   */
  5.  
  6. /* ------------------------ Function Definitions ------------------------- */
  7.  
  8. int indexed_file(int *file_handle,int operation,char passed_string[],unsigned char key_no);
  9.                                                         /* The main function. */
  10. /* The first argument is a user-program-defined integer variable which is set */
  11. /*  by the routine when a file is opened.  One variable should be defined for */
  12. /*  each file opened (such as "int ar-file,in-file;").  The next argument is  */
  13. /*  the function code (such as I_F_OPEN_WRITE).  The next is a pointer to the */
  14. /*  file name string or record array defined in the user's program.  Last is  */
  15. /*  the key number.  The first two arguments must always be defined; the      */
  16. /*  record string and key arguments may be replaced by "" and 0 when they are */
  17. /*  not relevant.  See the function codes below for the last two arguments'   */
  18. /*  requirements.                                                             */
  19.  
  20.  
  21. extern long i_f_next_file_attribute(char reset_flag);
  22. /* If this function is called with an argument of 1 it returns the first      */
  23. /*  value in the I_F_FILE_ATTRIBUTES string; an argument of 0 returns the     */
  24. /*  next, etc.; -1 is returned when no more exist.  This function can only be */
  25. /*  called when that string is set, usually by the function code              */
  26. /*  I_F_REPORT_ATTRIBUTES.  It is provided for the programmers' convenience.  */
  27. /*  The first attribute is the record length (0 for variable); the second is  */
  28. /*  the number of keys; then, for each key, are 3 numbers:  position, length, */
  29. /*  duplicates flag (0 for none; non-zero for duplicates allowed).            */
  30.  
  31. /* ----------------------- Routine's Functions ------------------------------ */
  32.  
  33. /* These are the file operations. */
  34. #define I_F_CLOSE               0
  35.     /* Requires neither the 3rd nor 4th (key) arguments be defined. */
  36. #define I_F_OPEN_READ           1
  37.     /* 3rd argument is pointer to filename string; 4th irrelevant. */
  38. #define I_F_OPEN_WRITE          2  /* (This requires I_F_FILE_ATTRIBUTES set) */
  39.     /* 3rd argument is pointer to filename string; 4th irrelevant. */
  40. #define I_F_OPEN_IO             3
  41.     /* 3rd argument is pointer to filename string; 4th irrelevant. */
  42. #define I_F_CLOSE_ALL           4
  43.     /* 3rd and 4th arguments unneeded. */
  44.  
  45. /* These are the record operations.  All require the 3rd argument to be a  */
  46. /*  pointer to an array of char in memory, which is the record area.       */
  47. #define I_F_READ               16  /* 4th arg. should be the key # to read. */
  48. #define I_F_START              17  /* 4th arg. is key to start by. */
  49. #define I_F_READNEXT           18  /* 4th arg. is irrelevant. */
  50. #define I_F_READPREV           19  /* (This is not currently implemented) */
  51. #define I_F_WRITE              20  /* 4th arg. is irrelevant. */
  52. #define I_F_REWRITE            21  /* 4th arg. is irrelevant. */
  53. #define I_F_DELETE             22  /* 4th arg. is irrelevant. */
  54.  
  55. #define I_F_REPORT_ATTRIBUTES  50  /* This sets the string I_F_FILE_ATTRIBUTES.*/
  56.  
  57.  
  58. /* ------------------------ Error Codes Returned ------------------------ */
  59.  
  60. #define I_F_SUCCESS                 0
  61. #define I_F_ERROR_KEYNOTFOUND       1
  62. #define I_F_ERROR_KEYEXISTS         2
  63. #define I_F_ERROR_BADOPERATION     16
  64. #define I_F_ERROR_BADHANDLE        17
  65. #define I_F_ERROR_BADKEY           18
  66. #define I_F_ERROR_BADFILENAME      19
  67. #define I_F_ERROR_BADATTRIBUTES    20
  68. #define I_F_ERROR_BADREVLEVEL      21
  69. #define I_F_ERROR_OUTOFMEMORY      50
  70. #define I_F_ERROR_SHAREWARE_LIMITS 51
  71. #define I_F_ERROR_INTERNAL         98
  72. #define I_F_ERROR_FILECORRUPTED    99
  73.  
  74.  
  75. /* ------------------------- Attribute Variables --------------------------*/
  76.  
  77. extern unsigned short I_F_RECORD_LENGTH;
  78. /* If the record length specified in I_F_FILE_ATTRIBUTES is 0, then this  */
  79. /*  variable should be set before ANY write/rewrite operation and checked */
  80. /*  after any read operation.  WARNING: the file engine uses this variable*/
  81. /*  internally; make sure you set/check it before/after EVERY operation;  */
  82. /*  don't assume that it has remained unchanged since you used it last!   */
  83.  
  84. extern char I_F_FILE_ATTRIBUTES[128];
  85. /* The user gives key info., etc. here.  Format: numbers seperated by spaces. */
  86. /*  First no. is fixed record length or 0.  The next number is the # of keys. */
  87. /*  Then, for each key, read 3 numbers (position, length, and duplicates).    */
  88.  
  89. extern char I_F_DIRECTION;
  90. /* This variable determines which direction start, read, and read-next     */
  91. /*  operations search when setting the new "current record pointer"; it    */
  92. /*  determines in which direction the file is to be accessed.  A 0 value   */
  93. /*  represents backwards access and non-zero means forward access.  Note   */
  94. /*  that one of these operations (start, read, or read-next must be called */
  95. /*  each time the direction is changed for the direction change to take    */
  96. /*  effect...                                                              */
  97.  
  98.